package com.hcw.bankdemo.exception;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName ServiceException
 * @description:自定义服务异常统一捕捉
 * @author: hcw
 * @time: 2020/8/29 12:15
 */
@Slf4j
public class ServiceException extends RuntimeException {
    private static final long serialVersionUID = 1L;
    //异常模板
    @Getter
    @Setter
    private ExceptionEnum exceptionEnum;
    @Getter
    @Setter
    private String msg;
    @Getter
    @Setter
    private  Exception exception;


    public ServiceException(String message, ExceptionEnum exceptionEnum,Exception exception) {
        super(message);
        //记录打印异常信息
        if (exception == null) {
            log.info(message);
        }else{
            log.info("统一异常捕获：",exception);
        }
        this.exceptionEnum = exceptionEnum;
        this.msg = message;
    }
}

